﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Xml.XmlDocument>" %>
<%= Documents.Common.Helpers.XmlHelper.TransformXML(Model,Server.MapPath(@"~\Transforms\History.xslt")) %>

<script type="text/javascript">
    $("#history tbody tr").click(function() {
       var loadeddocumentid = $("#showhistorybutton").attr("documentid");
        var requesteddocumentid = $(this).attr("documentid");
        // Store a boolean to represent the fact that this was loaded from history
        // This will allow the document, when loaded, to check to see if history is required to be loaded
        $("#state #documentOrigin").val("history");
        if (loadeddocumentid == requesteddocumentid) {
            ShowDocument();
            return;
        }
        $("#history tbody tr").removeClass("selected");
        $(this).addClass("selected");
        var eventArgs = { sensitive: $(this).attr("sensitive"), documentid: $(this).attr("documentid") };
        eventHub.RaiseEvent(DocumentEvents.OnDocumentSelect, eventArgs);
    });

    function ShowDocument() {
        // Hide history
        $("#historycontainer").addClass("hidden");
        // Show document        
        $("#documentcontainer").removeClass("hidden");
    }
    
    $("#showdocumentbutton").click(function() {
        // Hide history
        $("#historycontainer").addClass("hidden");
        // Show document        
        $("#documentcontainer").removeClass("hidden");
    });
</script>
